package m.member.manage.service;

import m.common.model.util.ModelCheckUtil;
import m.common.model.util.ModelUpdateUtil;
import m.common.service.Service;
import m.member.manage.model.MemberLevel;
import m.system.util.GenerateID;
import m.system.util.ObjectUtil;
import manage.util.DictionaryUtil;

public class MemberLevelService extends Service {
    public String save(MemberLevel model) throws Exception {
        ModelCheckUtil.checkNotNull(model,"color","name","discount");
        ModelCheckUtil.checkUniqueCombine(model,new String[]{"name"});
        String msg;
        if (ObjectUtil.isEmptyOid(model)) {
            model.setOid(GenerateID.generatePrimaryKey());
            ModelUpdateUtil.insertModel(model);
            msg="保存成功";
        }else{
            ModelUpdateUtil.updateModel(model);
            msg="修改成功";
        }
        DictionaryUtil.clear(MemberLevel.class);
        return msg;
    }
}
